package com.vecspace.dayu.code.ui.httphandler;

import org.springframework.beans.factory.annotation.Autowired;

import com.vecspace.dayu.code.ui.pojo.DataTree;
import com.vecspace.dayu.code.ui.service.DataTreeService;
import com.vecspace.security.model.LoginContext;
import com.vecspace.web.servlet.model.BaseController;
import com.vecspace.web.servlet.model.HController;
import com.vecspace.web.servlet.model.Param;
import com.vecspace.web.servlet.model.Path;

/** DAYU-页面树结构配置 httphandler
 * 在handler中进行与页面相关的处理，比如把数据转换为HTML格式等。
 * @author wanghua
*/
@HController("dayucode_dataTreeHandler")
public class DataTreeHandler extends BaseController {

	/**根据ID查询 DAYU-页面树结构配置
	 * @return DataTree
	 * @throws Exception
	 * @author wanghua
	 */
	@Path("getDataTree")
	public DataTree getDataTree(@Param("id") Long id) throws Exception {
		return dataTreeService.getDataTree(id);
	}
	
	/** 插入或修改 DAYU-页面树结构配置 
	 * @param item	要保存的对象
	 * @return void
	 * @throws Exception
	 * @author wanghua
	 */
	@Path("saveDataTree")
	public DataTree saveDataTree(@Param("item") DataTree item) throws Exception {
		if (item == null){
			return null;
		}
		/*** 对item对象进行校验，如必填项，格式，逻辑关系等 ***/
		String loginUserId = LoginContext.getLoginId();
		return dataTreeService.saveViewDataTree(item, loginUserId);
	}

	/** 根据ID删除 DAYU-页面树结构配置 
	 * @param id	主键值
	 * @return void
	 * @throws Exception
	 * @author wanghua
	 */
	@Path("deleteDataTree")
	public void deleteDataTree(@Param("id") Long id) throws Exception {
		dataTreeService.deleteDataTree(id);
	}

	/************* property ********************/
	@Autowired
	private DataTreeService dataTreeService;

}
